package com.suray.system.run.core;

import java.util.Date;
import java.util.Objects;

/**
 * 充电信息
 */
public class ChargeInfo extends BaseInfo {

    /**
     * 充电时间
     */
    private Integer chargeTime;

    /**
     * 充电开始时的时间
     */
    private Date chargeStartTime;

    /**
     * 充电开始时的电量
     */
    private Integer chargeStartSoc;

    /**
     * 充电结束时间
     */
    private Date chargeEndTime;

    /**
     * 充电结束时的电量
     */
    private Integer chargeEndSoc;

    /**
     * 本次充电是否异常
     */
    private boolean chargeError;

    /**
     * 充电异常信息
     */
    private Integer chargeErrorMessage;

    public Integer getChargeTime() {
        return chargeTime;
    }

    public Date getChargeStartTime() {
        return chargeStartTime;
    }

    public void setChargeStartTime(Date chargeStartTime) {
        this.chargeStartTime = chargeStartTime;
    }

    public Integer getChargeStartSoc() {
        return chargeStartSoc;
    }

    public void setChargeStartSoc(Integer chargeStartSoc) {
        this.chargeStartSoc = chargeStartSoc;
    }

    public Date getChargeEndTime() {
        return chargeEndTime;
    }

    public void setChargeEndTime(Date chargeEndTime) {
        this.chargeEndTime = chargeEndTime;
        this.chargeTime = (int)(this.chargeEndTime.getTime() - this.chargeStartTime.getTime());
    }

    public Integer getChargeEndSoc() {
        return chargeEndSoc;
    }

    public void setChargeEndSoc(Integer chargeEndSoc) {
        this.chargeEndSoc = chargeEndSoc;
    }

    public boolean isChargeError() {
        return chargeError;
    }

    public void setChargeError(boolean chargeError) {
        this.chargeError = chargeError;
    }

    public Integer getChargeErrorMessage() {
        return chargeErrorMessage;
    }

    public void setChargeErrorMessage(Integer chargeErrorMessage) {
        this.chargeErrorMessage = chargeErrorMessage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        ChargeInfo that = (ChargeInfo) o;
        return chargeError == that.chargeError &&
                Objects.equals(chargeTime, that.chargeTime) &&
                Objects.equals(chargeStartTime, that.chargeStartTime) &&
                Objects.equals(chargeStartSoc, that.chargeStartSoc) &&
                Objects.equals(chargeEndTime, that.chargeEndTime) &&
                Objects.equals(chargeEndSoc, that.chargeEndSoc) &&
                Objects.equals(chargeErrorMessage, that.chargeErrorMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), chargeTime, chargeStartTime, chargeStartSoc, chargeEndTime, chargeEndSoc, chargeError, chargeErrorMessage);
    }
}
